import { ModuleMetadata, Type } from "@nestjs/common";
import { Prisma } from "@prisma/client";


export interface PrismaModuleOptions {
    url?: string;
    options?: Prisma.TransactionClient;
    name?: string;
    retryAttempts?: number;
    retryDelay?: number;
    conectionFactory?: (connection: any, client: any) => any;
    conectionErrorFactory?: (error: any) => any;
}

export interface PrismaOptionsFactory {
    createPrismaModuleOptions(): Promise<PrismaModuleOptions>
}

export type PrismaModuleFactoryOptions = Omit<PrismaModuleOptions, 'name'>

export interface PrismaModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
    name?: string;
    useExisting?: Type<PrismaOptionsFactory>;
    useClass?: Type<PrismaOptionsFactory>;
    useFactory?: (...args: any[]) => Promise<PrismaModuleFactoryOptions> | PrismaModuleFactoryOptions;
    inject?: any
}